<?php

if(!isset($_GET['id']))
{
	$Error = 'Concours inexistant';
	$SkinTitle = 'µContest - Concours inexistant';
}
else
{
	$contest = GetContestById($_GET['id']);
	if($contest === false)
	{
		$Error = 'Concours inexistant';
		$SkinTitle = 'µContest - Concours inexistant';
	}
	else
	{
		$SkinTitle = 'µContest - ' . $contest->title;
		$category = GetCategoryById($contest->category);
	}
}

$UsersCount = GetUsersCount();

?>

<div class="mc_box">
	<h3><?php if(isset($Error)) echo 'Erreur'; else echo '<a href="contests.php">Liste des épreuves</a> :: <a href="contests.php?id=' . $category->id . '">' . stripslashes($category->title) . '</a> :: ' . stripslashes($contest->title) . ' (' . $contest->id . ')'; ?><?php if($mcuser->isadmin) echo '<a href="admin/contestedit.php?id=' . $contest->id . '"><span style="padding-left:10px; font-size:.6em;">Edit</a></a>'; ?></h3>	
	<div class="mc_contest_view_text">
		<?php if(isset($Error)) echo "<font color=\"red\"><b>$Error</b></font>"; 
		else
		{
		?>
			<div id="mc_summary">
				<div style="float: right;"><?php if(IsValidated($mcuser, $contest->id)) echo '<img src="img/check.png" />'; ?></div>
				<h3 style="margin: 0; margin-bottom: 10px; padding-top: 4px;">Résumé</h3>
				<table>
					<tr>
						<td>ID :</td>
						<td style="padding-left: 10px;"><?php echo $contest->id; ?></td>
					</tr>
					<tr>
						<td>Points :</td>
						<td style="padding-left: 10px;"><?php echo $contest->points ?></td>
					</tr>
					<tr>
						<td>Validations :</td>
						<td style="padding-left: 10px;"><?php echo 100*$contest->validationcount/$UsersCount; ?> %</td>
					</tr>
				</table>
			</div>
		
			<h3 style="border-style: none;"><i><u>Description</u></i></h3><br />
			<?php echo nl2br(stripslashes($contest->description)); ?>
			
			<br /><br />
			<h3 style="border-style: none;"><i><u>Variables</u></i></h3><br />
			<?php echo nl2br(stripslashes($contest->variables)); ?>
			
			<br /><br />
			
		<?php
		}
		?>
	</div>
</div>